﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Security.Cryptography;


namespace miniLib.Helpers
{
    /// <summary>
    /// SqlServer数据访问帮助类
    /// </summary>
    public sealed class HashHelper
    {
        public static string GetHash(string algorithms, byte[] data)
        {
            HashAlgorithm hash = algorithms.ToUpper() switch
            {
                "SHA512" => SHA512.Create(),
                "SHA384" => SHA384.Create(),
                "SHA256" => SHA256.Create(),
                "MD5" => MD5.Create(),
            };
            return Convert.ToBase64String(hash.ComputeHash(data));
        }
    }
}
